# Purpose of this class is to act as a UDP SERVER on the tank itself
import sys
import os
import thread
import time

import classDebug
from classSensor import *
from classTank import *
#import classChatServer
from classMotor import *
from classK8055 import *
from classOutput import *

vm1 = K8055(0)

# Create some outputs
leftDirOutput			= OutputVm("DO",vm1,2)
rightDirOutput			= OutputVm("DO",vm1,3)
leftSpeedOutput		= OutputVm("AO",vm1,1)
rightSpeedOutput		= OutputVm("AO",vm1,2)

print "output type: "+rightSpeedOutput.type

# Create some Sensors
incSensor = Sensor("inc")
tiltSensor = Sensor("tilt",0,100,0,100,"deg",0.1,10)
tiltSensor.simulate=True

simSensor = Sensor("sim",0,100,0,100,"%",0.1,10)
simSensor.simulate=True

Sensor.CgetList()


# Create Motors
leftMainMotor = Motor("M1")
rightMainMotor = Motor("M2")
rightMainMotor.inverted = True

# Add outputs to motors
leftMainMotor.attachOutput(leftDirOutput)
leftMainMotor.attachOutput(leftSpeedOutput)

rightMainMotor.attachOutput(rightDirOutput)
rightMainMotor.attachOutput(rightSpeedOutput)

bigTank = Tank("MyTank",23000)
bigTank.addSensors(simSensor)
bigTank.addSensors(tiltSensor)
bigTank.addMotor(leftMainMotor,"left")
bigTank.addMotor(rightMainMotor,"right")


while not bigTank.breakLoop:
	time.sleep(1)


